/* 
 * File:   Pmp.cpp
 * Author: ejordan
 * 
 * Created on March 21, 2013, 10:50 PM
 */

#include <p32xxxx.h>
#include <plib.h>
#include "Pmp.h"

/*! \brief Creates a new instance of a Parallel Master Port (PMP)
 *
 *  Creates a new instance of a VoltageReader
 */
Pmp::Pmp() { }

/*! \brief Initializes the PMP perpherial.
*/
void Pmp::Initialize()
{
	mPMPOpen(
		PMP_ON |
		PMP_IDLE_CON |
		PMP_MUX_OFF |
		PMP_ST |
		PMP_READ_WRITE_EN |
		PMP_CS2_CS1_EN |
		PMP_LATCH_POL_HI |
		PMP_CS2_POL_HI |
		PMP_CS1_POL_HI |
		PMP_WRITE_POL_HI |
		PMP_READ_POL_HI,

		PMP_IRQ_OFF |
		PMP_AUTO_ADDR_OFF |
		PMP_DATA_BUS_16 |
		PMP_MODE_MASTER1 |
		PMP_WAIT_BEG_4 |
		PMP_WAIT_MID_15 |
		PMP_WAIT_END_4,

		PMP_PEN_0,

		PMP_INT_OFF
		);

	T1CON = 0x8030;
	TMR1 = 0;
	while (TMR1 < 2000);
}

/*! \brief Closes the PMP perpherial.
*/
Pmp::~Pmp()
{
	mPMPClose();
}

/*! \brief Closes the PMP perpherial.
*/
void Pmp::Close()
{
	mPMPClose();
}